package com.zzj.handle;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.log4j.Log4j2;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@Log4j2
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("自动填充插入时间");
        this.strictInsertFill(metaObject, "createdAt", LocalDateTime.class,LocalDateTime.now()); // 起始版本 3.3.3(推荐)
        this.strictInsertFill(metaObject, "updatedAt", LocalDateTime.class,LocalDateTime.now()); // 起始版本 3.3.3(推荐)
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("自动填充更新时间");
        this.strictUpdateFill(metaObject, "updatedAt",LocalDateTime.class,LocalDateTime.now()); // 起始版本 3.3.3(推荐)
    }



}
